package org.testile.datasetgenerifier.impl;

import java.util.HashMap;
import java.util.Map;
import org.testile.datasetgenerifier.ColumnGenerifier;
import org.testile.datasetgenerifier.TableGenerifier;

/**
 *
 * @author ytoh
 */
public class DefaultTableGenerifier implements TableGenerifier {
	private Map<String, ColumnGenerifier> columnGenerifiers;

	public DefaultTableGenerifier() {
		this.columnGenerifiers = new HashMap<String, ColumnGenerifier>();
	}

	public DefaultTableGenerifier(Map<String, ColumnGenerifier> tableGenerifiers) {
		this.columnGenerifiers = tableGenerifiers;
	}

	public void addColumnGenerifier(String columnName, ColumnGenerifier generifier) {
		columnGenerifiers.put(columnName, generifier);
	}

	public ColumnGenerifier getColumnGenerifier(String columnName) {
		ColumnGenerifier columnGenerifier = columnGenerifiers.get(columnName);

		if(columnGenerifier == null) {
			columnGenerifier = new DefaultColumnGenerifier();
			columnGenerifiers.put(columnName, columnGenerifier);
		}

		return columnGenerifier;
	}
}
